﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class base_FileUpload : System.Web.UI.Page
{
    string t;
    protected void Page_Load(object sender, EventArgs e)
    {
        string error="";
        string msg="";
        HttpPostedFile fuFile = Request.Files[0];
        string fn = fuFile.FileName.Trim();
        Hashtable ht=new Hashtable();
        if (fn == "")
        {
            error="请选定上传文件";
            Response.Write("{error:\""+error+"\",msg:\""+msg+"\"}");
            Response.End();
        }
            if(fuFile.ContentLength>Params.MaxFileSize)
            {
                error = "上传文件大小不能超过" + Params.MaxFileSize.ToString() + "字节";
                Response.Write("{error:\"" + error + "\",msg:\"" + msg + "\"}");
                Response.End();
            }
        string exten=System.IO.Path.GetExtension(fn).Trim().ToLower();
        if (exten != ".xls")
        {
            error = "上传的文件必须为Excel";
            Response.Write("{error:\"" + error + "\",msg:\"" + msg + "\"}");
            Response.End();
        }
        string fp = Params.FilesFolderPath + Fun.GetFileName() + exten;
        try{
            fuFile.SaveAs(fp);
        }
        catch(Exception ee)
        {
            error=ee.Message;
            Response.Write("{error:\""+error+"\",msg:\""+msg+"\"}");
            Response.End();
        }
        this.t = Server.UrlDecode(Request.Params["type"]).Trim().ToLower();
        switch (t)
        {
            case LwUser.TeamType:
                break;
            case LwUser.DoctorType:
                break;
            case LwUser.StudentType:
                break;
            case Category.CategoryStr:
                break;
            default:
                error = "发生错误";
                break;
        }
        Response.Write("{error:\"" + error + "\",msg:\"" + msg + "\"}");
        Response.End();
    }
}
